<! DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>打出菱形</title>
</head>
<body>
<script>
    var str='';
    var n=prompt('请输入行数：');
    
    for(var i=1;i<=n;i++){
        for(var j=1;j<=n-i;j++){
            document.write('&nbsp');
        }
        for(k=1;k<=2*i-1;k++){
            document.write('*');

        }
        document.write('<br/>');
    }
    for(i=1;i<=n;i++){
        for(j=1;j<=i;j++){
            document.write('&nbsp');
        }
        for(k=1;k<=2*(n-i);k++){
            document.write('*')
        }
        document.write('<br/>')
    }
    
</script>
</body>
</html>
